package com.sun.weekend.util;

import org.greenrobot.eventbus.EventBus;

/**
 * @author sunleilei
 */

public class EventBusUtil {

    private static EventBus eventBus;
    private static EventBusUtil mInstance;
    private EventBusUtil(){
        eventBus = EventBus.getDefault();
    }

    public static EventBusUtil getInstance() {
        if (mInstance == null) {
            mInstance = new EventBusUtil();
        }
        return mInstance;
    }

    public void register(Object object) {
        eventBus.register(object);
    }

    public void unregister(Object object) {
        eventBus.unregister(object);
    }

    public void postEvent(EventBusBean busBean){
        eventBus.post(busBean);
    }

    public class EventBusBean{
        private String tag;
        private Object object;

        public EventBusBean(String tag) {
            this.tag = tag;
        }

        public String getTag() {
            return tag;
        }

        public void setTag(String tag) {
            this.tag = tag;
        }

        public Object getObject() {
            return object;
        }

        public void setObject(Object object) {
            this.object = object;
        }
    }
}
